<html>

<head>
	<meta charset="UTF-8"> 
	<style type="text/css">
		#myCanvas{
			border: 1px solid #ccc;
		}
	</style>
	<script type="text/javascript" src='js/jquery-1.11.1.js'></script>

	<script type="text/javascript">
		$().ready(function(){
			var canvas = document.getElementById("myCanvas");
			var context = canvas.getContext("2d");

			context.beginPath();
			// 起点
			context.moveTo(100,100);
			// 第二个点
			context.lineTo(300,150);
			// 第三个点
			context.lineTo(300,60);
			// 负责闭合
			context.closePath();
			// 绘制线
			context.strokeStyle = "red";
			context.stroke();
			// 填充
			context.fillStyle = "blue";
			context.fill();
		});

	</script>

    <title>Canvas 绘制线条</title>
</head>

<body>
	<canvas id="myCanvas" width="400" height="300"></canvas>
</body>
</html>
